﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DBUtility;

public partial class Control_NewsInfo : System.Web.UI.UserControl
{
    MODEL.News MN = new MODEL.News();

    BLL.News BN = new BLL.News();

    protected void Page_Load(object sender, EventArgs e)
    {
        ControlDataInit();
    }


    #region ControlDataInit
    protected void ControlDataInit()
    {
        if (Request.QueryString["NewsID"] == null)
        {
            Response.Redirect("News.aspx");
        }
        else
        {
            string NewsID = Request.QueryString["NewsID"].ToString();

            string SQLstr = "SELECT News.*, NewsClass.NC_Title FROM (News INNER JOIN NewsClass ON ";
            SQLstr += "News.News_ClassID = NewsClass.NC_ID) WHERE (News.News_ID = " + NewsID + ")";

            DataTable DT_NewsInfo = AccHelper.GetDataTable(SQLstr);

            LB_Class.Text = DT_NewsInfo.Rows[0]["NC_Title"].ToString();
            LB_Content.Text = DT_NewsInfo.Rows[0]["News_Content"].ToString();
            LB_DateTime.Text = DT_NewsInfo.Rows[0]["News_DateTime"].ToString();
            LB_Hits.Text = DT_NewsInfo.Rows[0]["News_Hits"].ToString();
            LB_Title.Text = DT_NewsInfo.Rows[0]["News_Title"].ToString();

            MN.News_ID = Convert.ToInt32(NewsID);

            BN.HitsPlus1(MN);
        }

        

    }
    #endregion
}
